using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.Source.UI.Chat.Map;
using MicroMsg.Storage;
using MicroMsg.UI.Chat.Map;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Controls.Maps;
using Microsoft.Phone.Shell;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Device.Location;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Xml.Linq;
namespace MicroMsg.UI.Page
{
	public class MapPage : BasePage
	{
		public enum PageType
		{
			SendPage,
			ReceivePage
		}
		private const string TAG = "MapPage";
		private const uint MAX_INDEX = 2u;
		private const int INTERVAL_TIME = 200;
		private string LOADSTRING = strings.Map_Loading;
		private string WAITSTRING = strings.Map_Getting_LocationInfo;
		private MapPage.PageType _pageType;
		private HttpWebRequest _request;
		private bool _hasGetAddress;
		private GeoCoordinate _firstLocation = new GeoCoordinate();
		private GeoCoordinate _firstNotAccLocation = new GeoCoordinate();
		private GeoCoordinate _gpsLocation = new GeoCoordinate();
		private bool _isPageOut;
		private Storyboard _gridInfoReceiveShowStoryboard;
		private Storyboard _gridInfoReceiveHideStoryboard;
		public static string strAddress;
		public Pushpin oldPushpin;
		private DispatcherTimer _dt;
		private BackgroundWorker _bw;
		private OffsetConverter _offsetConverter;
		public string _cuUser;
		private GeoCoordinateWatcher mGeoWatcher;
		private double latitude;
		private double longitude;
		private bool _isFirstGetAddress = true;
		private double _lastLat = double.NaN;
		private double _lastLng = double.NaN;
		private bool _isCenterChanging;
		private uint _indexForCenterChanging;
		private bool isFingerPressed;
		private double tempLat;
		private double tempLng;
		internal Storyboard StoryboardJump;
		internal Grid LayoutRoot;
		internal Map myMap;
		internal MapTileLayer myMapTileLayer;
		internal MapLayer mapLayerReceive;
		internal Grid panelReceive;
		internal Grid gridInfoReceive;
		internal StackPanel spInfoReceive;
		internal TextBlock tbUserLeft;
		internal TextBlock tbUserName;
		internal TextBlock tbUserRight;
		internal TextBlock tbAddressReceive;
		internal Image imgPushinReceive;
		internal MapLayer mapLayerAccuracy;
		internal Ellipse ellipseAccuracy;
		internal Grid panelSend;
		internal Grid gridInfoSend;
		internal TextBlock tbAddressSend;
		internal Image imgPushinSend;
		internal Image imgLogo;
		internal ApplicationBarIconButton OpenMapBtn;
		private bool _contentLoaded;
		public MapPage()
		{
			this.InitializeComponent();
		}
		public static void SelectCustomMapPage(BasePage originPage, MapPage.PageType pageType, string userName = "", double latitudeParam = 30.259497, double longitudeParam = 120.129798, double scale = 16.0, string address = "")
		{
			if (pageType == MapPage.PageType.SendPage && !string.IsNullOrEmpty(userName))
			{
				originPage.GoToPage("/Source/UI/Chat/Map/MapPage.xaml", new object[]
				{
					MapPage.PageType.SendPage,
					userName,
					address,
					latitudeParam,
					longitudeParam,
					scale
				}, false);
				return;
			}
			if (pageType == MapPage.PageType.ReceivePage)
			{
				originPage.GoToPage("/Source/UI/Chat/Map/MapPage.xaml", new object[]
				{
					MapPage.PageType.ReceivePage,
					userName,
					address,
					latitudeParam,
					longitudeParam,
					scale
				}, false);
			}
		}
		public static object[] GetMapPageArg(BasePage originPage, MapPage.PageType pageType, string userName = "", double latitudeParam = 30.259497, double longitudeParam = 120.129798, double scale = 16.0, string address = "")
		{
			object[] array = new object[6];
			if (pageType == MapPage.PageType.SendPage && !string.IsNullOrEmpty(userName))
			{
				array[0] = MapPage.PageType.SendPage;
				array[1] = userName;
				array[2] = address;
				array[3] = latitudeParam;
				array[4] = longitudeParam;
				array[5] = scale;
			}
			else
			{
				if (pageType == MapPage.PageType.ReceivePage)
				{
					array[0] = MapPage.PageType.ReceivePage;
					array[1] = userName;
					array[2] = address;
					array[3] = latitudeParam;
					array[4] = longitudeParam;
					array[5] = scale;
				}
			}
			return array;
		}
		protected override void OnPageIn(object[] object_0)
		{
			if (object_0 != null && Enumerable.Count<object>(object_0) > 0)
			{
				this._pageType = (MapPage.PageType)object_0[0];
				if (this._pageType == MapPage.PageType.SendPage)
				{
					string cuUser = object_0[1] as string;
					this._cuUser = cuUser;
					Log.smethod_5("MapPage", "SEND_PAGE GeoLocationLoaded start");
					this._bw = new BackgroundWorker();
					this._bw.add_RunWorkerCompleted(new RunWorkerCompletedEventHandler(this.LoadOffsetDataCompleted));
					this._bw.add_DoWork(new DoWorkEventHandler(this.LoadOffsetData));
					this._bw.RunWorkerAsync();
					this.StartLocationService();
					if (base.get_ApplicationBar() != null && base.get_ApplicationBar().get_Buttons() != null && base.get_ApplicationBar().get_Buttons().get_Count() != 0)
					{
						ApplicationBarIconButton applicationBarIconButton = base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton;
						if (applicationBarIconButton != null)
						{
							applicationBarIconButton.set_IsEnabled(true);
							applicationBarIconButton.set_IconUri(new Uri("/Resource/Img/CommonUse/ico_save.png", 2));
							applicationBarIconButton.set_Text(strings.COM_Send);
							return;
						}
					}
				}
				else
				{
					if (this._pageType == MapPage.PageType.ReceivePage && Enumerable.Count<object>(object_0) > 3)
					{
						this.myMap.set_Visibility(0);
						this.InitGoogleMap();
						this.myMap.AnimationLevel = AnimationLevel.None;
						this.imgLogo.set_Visibility(0);
						this.imgLogo.set_Margin(new Thickness(5.0, 0.0, 0.0, 5.0));
						string text = object_0[1] as string;
						string text2 = object_0[2] as string;
						this.latitude = (double)object_0[3];
						this.longitude = (double)object_0[4];
						double num = (double)object_0[5];
						this.myMap.add_Tap(new EventHandler<GestureEventArgs>(this.myMap_Tap));
						this.myMap.Center = new GeoCoordinate(this.latitude, this.longitude);
						this.myMap.ZoomLevel = num + 1.0;
						MapLayer.SetPosition(this.panelReceive, new GeoCoordinate(this.latitude, this.longitude));
						MapLayer.SetPositionOrigin(this.panelReceive, PositionOrigin.BottomCenter);
						this.imgPushinReceive.add_Tap(new EventHandler<GestureEventArgs>(this.imgPushinReceive_Tap));
						UIElement arg_283_0 = this.gridInfoReceive;
						CompositeTransform compositeTransform = new CompositeTransform();
						compositeTransform.set_ScaleX(0.0);
						compositeTransform.set_ScaleY(0.0);
						arg_283_0.set_RenderTransform(compositeTransform);
						this.gridInfoReceive.set_RenderTransformOrigin(new Point(0.5, 1.0));
						this._gridInfoReceiveShowStoryboard = new Storyboard();
						DoubleAnimation doubleAnimation = new DoubleAnimation();
						doubleAnimation.set_Duration(new TimeSpan(0, 0, 0, 0, 300));
						doubleAnimation.set_To(new double?(1.0));
						DoubleAnimation doubleAnimation2 = doubleAnimation;
						Storyboard.SetTargetProperty(doubleAnimation2, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.ScaleX)", new object[0]));
						Storyboard.SetTarget(doubleAnimation2, this.gridInfoReceive);
						DoubleAnimation arg_336_0 = doubleAnimation2;
						BackEase backEase = new BackEase();
						backEase.set_EasingMode(0);
						backEase.set_Amplitude(0.5);
						arg_336_0.set_EasingFunction(backEase);
						this._gridInfoReceiveShowStoryboard.get_Children().Add(doubleAnimation2);
						DoubleAnimation doubleAnimation3 = new DoubleAnimation();
						doubleAnimation3.set_Duration(new TimeSpan(0, 0, 0, 0, 300));
						doubleAnimation3.set_To(new double?(1.0));
						DoubleAnimation doubleAnimation4 = doubleAnimation3;
						Storyboard.SetTargetProperty(doubleAnimation4, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.ScaleY)", new object[0]));
						Storyboard.SetTarget(doubleAnimation4, this.gridInfoReceive);
						DoubleAnimation arg_3CE_0 = doubleAnimation4;
						BackEase backEase2 = new BackEase();
						backEase2.set_EasingMode(0);
						backEase2.set_Amplitude(0.7);
						arg_3CE_0.set_EasingFunction(backEase2);
						this._gridInfoReceiveShowStoryboard.get_Children().Add(doubleAnimation4);
						ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames = new ObjectAnimationUsingKeyFrames();
						Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames, new PropertyPath("(UIElement.Visibility)", new object[0]));
						Storyboard.SetTarget(objectAnimationUsingKeyFrames, this.gridInfoReceive);
						PresentationFrameworkCollection<ObjectKeyFrame> arg_441_0 = objectAnimationUsingKeyFrames.get_KeyFrames();
						DiscreteObjectKeyFrame discreteObjectKeyFrame = new DiscreteObjectKeyFrame();
						discreteObjectKeyFrame.set_KeyTime(new TimeSpan(0, 0, 0));
						discreteObjectKeyFrame.set_Value(0);
						arg_441_0.Add(discreteObjectKeyFrame);
						this._gridInfoReceiveShowStoryboard.get_Children().Add(objectAnimationUsingKeyFrames);
						this._gridInfoReceiveHideStoryboard = new Storyboard();
						DoubleAnimation doubleAnimation5 = new DoubleAnimation();
						doubleAnimation5.set_Duration(new TimeSpan(0, 0, 0, 0, 300));
						doubleAnimation5.set_To(new double?(0.0));
						DoubleAnimation doubleAnimation6 = doubleAnimation5;
						Storyboard.SetTargetProperty(doubleAnimation6, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.ScaleX)", new object[0]));
						Storyboard.SetTarget(doubleAnimation6, this.gridInfoReceive);
						DoubleAnimation arg_4E4_0 = doubleAnimation6;
						BackEase backEase3 = new BackEase();
						backEase3.set_EasingMode(1);
						backEase3.set_Amplitude(0.5);
						arg_4E4_0.set_EasingFunction(backEase3);
						this._gridInfoReceiveHideStoryboard.get_Children().Add(doubleAnimation6);
						DoubleAnimation doubleAnimation7 = new DoubleAnimation();
						doubleAnimation7.set_Duration(new TimeSpan(0, 0, 0, 0, 300));
						doubleAnimation7.set_To(new double?(0.0));
						DoubleAnimation doubleAnimation8 = doubleAnimation7;
						Storyboard.SetTargetProperty(doubleAnimation8, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.ScaleY)", new object[0]));
						Storyboard.SetTarget(doubleAnimation8, this.gridInfoReceive);
						DoubleAnimation arg_57C_0 = doubleAnimation8;
						BackEase backEase4 = new BackEase();
						backEase4.set_EasingMode(1);
						backEase4.set_Amplitude(0.7);
						arg_57C_0.set_EasingFunction(backEase4);
						this._gridInfoReceiveHideStoryboard.get_Children().Add(doubleAnimation8);
						ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames2 = new ObjectAnimationUsingKeyFrames();
						Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames2, new PropertyPath("(UIElement.Visibility)", new object[0]));
						Storyboard.SetTarget(objectAnimationUsingKeyFrames2, this.gridInfoReceive);
						PresentationFrameworkCollection<ObjectKeyFrame> arg_5F5_0 = objectAnimationUsingKeyFrames2.get_KeyFrames();
						DiscreteObjectKeyFrame discreteObjectKeyFrame2 = new DiscreteObjectKeyFrame();
						discreteObjectKeyFrame2.set_KeyTime(new TimeSpan(0, 0, 0, 0, 300));
						discreteObjectKeyFrame2.set_Value(1);
						arg_5F5_0.Add(discreteObjectKeyFrame2);
						this._gridInfoReceiveHideStoryboard.get_Children().Add(objectAnimationUsingKeyFrames2);
						if (AccountMgr.strUsrName.Equals(text))
						{
							this.tbUserName.set_Text(strings.Chat_My_Location);
						}
						else
						{
							this.tbUserName.set_Text(ContactHelper.getDisplayName(text, null));
							string text3 = string.Format(strings.Chat_Others_Location, this.tbUserName.get_Text());
							this.tbUserLeft.set_Text(text3.Substring(0, text3.IndexOf(this.tbUserName.get_Text())));
							this.tbUserRight.set_Text(text3.Substring(text3.IndexOf(this.tbUserName.get_Text()) + this.tbUserName.get_Text().get_Length()));
						}
						if (!string.IsNullOrEmpty(text2))
						{
							this.tbAddressReceive.set_Text(text2);
							this.tbAddressReceive.set_Visibility(0);
						}
						else
						{
							this.tbAddressReceive.set_Visibility(1);
							this.GetData(this.latitude, this.longitude);
						}
						Log.smethod_5("MapPage", "RECIEVE_PAGE GeoLocationLoaded start");
						base.get_ApplicationBar().set_IsVisible(false);
						DispatcherTimer dispatcherTimer_0 = new DispatcherTimer();
						dispatcherTimer_0.set_Interval(new TimeSpan(0, 0, 0, 0, 500));
						dispatcherTimer_0.add_Tick(delegate(object sender, EventArgs e)
						{
							dispatcherTimer_0.Stop();
							this.mapLayerReceive.set_Visibility(0);
							this._gridInfoReceiveShowStoryboard.Begin();
						});
						dispatcherTimer_0.Start();
					}
				}
			}
		}
		private void imgPushinReceive_Tap(object sender, GestureEventArgs e)
		{
			this._gridInfoReceiveShowStoryboard.Begin();
			e.set_Handled(true);
		}
		private void myMap_Tap(object sender, GestureEventArgs e)
		{
			this._gridInfoReceiveHideStoryboard.Begin();
		}
		private void imgPushinReceive_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
		{
			this._gridInfoReceiveShowStoryboard.Begin();
			e.set_Handled(true);
		}
		private void myMap_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
		{
			this._gridInfoReceiveHideStoryboard.Begin();
		}
		private void LoadOffsetData(object sender, DoWorkEventArgs e)
		{
			this._offsetConverter = new OffsetConverter();
			this._offsetConverter.LoadData();
		}
		private void LoadOffsetDataCompleted(object sender, RunWorkerCompletedEventArgs e)
		{
			base.get_Dispatcher().BeginInvoke(delegate
			{
				if (!this._firstLocation.get_IsUnknown() && !this._isPageOut)
				{
					this._offsetConverter.OnGetNoOffsetLocationCompeleted += new EventHandler(this.GetNoOffsetLocationCompeleted);
					this._offsetConverter.GetOffsetLocation(this._firstLocation);
				}
			});
		}
		protected override void OnPageOut()
		{
			this.hideProgressCover();
			this._isPageOut = true;
			if (this._offsetConverter != null)
			{
				this._offsetConverter.Dispose();
				this._offsetConverter = null;
			}
			if (this._dt != null && this._dt.get_IsEnabled())
			{
				this._dt.Stop();
				this._dt.remove_Tick(new EventHandler(this.dt_Tick));
				this._dt = null;
			}
			if (this._request != null && !this._request.get_HaveResponse())
			{
				this._request.Abort();
				this._request = null;
			}
			this.StopLocationService();
			base.OnPageOut();
		}
		protected override void OnPageBack()
		{
			this.hideProgressCover();
			base.GoBack();
			base.OnPageBack();
		}
		private void InitGoogleMap()
		{
			this.myMapTileLayer.TileSources.Clear();
			this.myMapTileLayer.TileSources.Add(new GoogleTileSource());
		}
		private void showProgressCover(string strCoverTitle, bool hasLocation)
		{
			if (hasLocation)
			{
				ProcessingCover.setProgressBarTitle(this.LayoutRoot, strCoverTitle, null, false, true, new RoutedEventHandler(this.btnOk_Click));
			}
			else
			{
				ProcessingCover.setProgressBarTitle(this.LayoutRoot, strCoverTitle, null, false, false, null);
			}
			base.get_ApplicationBar().set_IsVisible(false);
		}
		private void hideProgressCover()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
			base.get_ApplicationBar().set_IsVisible(true);
		}
		private void StartLocationService()
		{
			Log.smethod_5("MapPage", "StartLocationService");
			this.StartLocationService(1);
		}
		private void StartLocationService(GeoPositionAccuracy accuracy)
		{
			if (this.mGeoWatcher == null)
			{
				this.mGeoWatcher = new GeoCoordinateWatcher(accuracy);
				this.mGeoWatcher.set_MovementThreshold(0.0);
				this.mGeoWatcher.add_StatusChanged(new EventHandler<GeoPositionStatusChangedEventArgs>(this.mGeoWatcher_StatusChanged));
				this.mGeoWatcher.add_PositionChanged(new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(this.mGeoWatcher_PositionChanged));
			}
			this.showProgressCover(strings.Lbs_PeoList_MsgGettingPos, false);
			this.mGeoWatcher.Start();
		}
		private void mGeoWatcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
		{
			Deployment.get_Current().get_Dispatcher().BeginInvoke(delegate
			{
				this.GeoStatusChanged(e);
			});
		}
		private void GeoStatusChanged(GeoPositionStatusChangedEventArgs geoPositionStatusChangedEventArgs_0)
		{
			switch (geoPositionStatusChangedEventArgs_0.get_Status())
			{
			case 0:
				this.hideProgressCover();
				this.geoDisable();
				Log.smethod_5("MapPage", "GeoPositionStatus.Disabled");
				return;
			case 1:
				Log.smethod_5("MapPage", "GeoPositionStatus.Ready");
				this.initGeoPostionSuccess();
				break;
			case 2:
				break;
			case 3:
				this.hideProgressCover();
				if (!this._isPageOut)
				{
					this.initGeoPostionFailed();
				}
				Log.smethod_5("MapPage", "GeoPositionStatus.NoData");
				return;
			default:
				return;
			}
		}
		private void mGeoWatcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
		{
			Deployment.get_Current().get_Dispatcher().BeginInvoke(delegate
			{
				this.GeoPositionChanged(e);
			});
		}
		private void GeoPositionChanged(GeoPositionChangedEventArgs<GeoCoordinate> geoPositionChangedEventArgs_0)
		{
			if (this.mGeoWatcher == null || this.mGeoWatcher.get_Status() != 1 || this._isPageOut)
			{
				return;
			}
			if (geoPositionChangedEventArgs_0.get_Position().get_Location().get_HorizontalAccuracy() > 500.0)
			{
				this._firstNotAccLocation = geoPositionChangedEventArgs_0.get_Position().get_Location();
				this.showProgressCover(strings.Map_GettingLocationMore, true);
				return;
			}
			if (this._offsetConverter.HasLoadData)
			{
				this._offsetConverter.OnGetNoOffsetLocationCompeleted += new EventHandler(this.GetNoOffsetLocationCompeleted);
				this._offsetConverter.GetOffsetLocation(geoPositionChangedEventArgs_0.get_Position().get_Location());
			}
			else
			{
				this._firstLocation = geoPositionChangedEventArgs_0.get_Position().get_Location();
			}
			this.StopLocationService();
		}
		private void btnOk_Click(object sender, EventArgs e)
		{
			this.StopLocationService();
			((Button)sender).set_IsEnabled(false);
			((Button)sender).set_Content(strings.Map_Waiting);
			if (this._offsetConverter.HasLoadData)
			{
				this._offsetConverter.OnGetNoOffsetLocationCompeleted += new EventHandler(this.GetNoOffsetLocationCompeleted);
				this._offsetConverter.GetOffsetLocation(this._firstNotAccLocation);
				return;
			}
			this._firstLocation = this._firstNotAccLocation;
		}
		private void GetNoOffsetLocationCompeleted(object sender, EventArgs e)
		{
			if (!this._isPageOut)
			{
				base.get_Dispatcher().BeginInvoke(delegate
				{
					this.myMap.set_Visibility(0);
					GeoCoordinate geoCoordinate = (GeoCoordinate)sender;
					this._gpsLocation = geoCoordinate;
					Log.smethod_5("MapPage", "NoOffsetLocation latitude = " + geoCoordinate.get_Latitude());
					Log.smethod_5("MapPage", "NoOffsetLocation longitude = " + geoCoordinate.get_Longitude());
					this.imgLogo.set_Visibility(0);
					this.hideProgressCover();
					this.InitGoogleMap();
					this.StoryboardJump.add_Completed(new EventHandler(this.StoryboardJump_Completed));
					this.panelSend.set_Visibility(0);
					this.myMap.MapZoom += new EventHandler<MapZoomEventArgs>(this.myMap_MapZoom);
					Touch.add_FrameReported(new TouchFrameEventHandler(this.Touch_FrameReported));
					this._dt = new DispatcherTimer();
					this._dt.set_Interval(new TimeSpan(0, 0, 0, 0, 200));
					this._dt.add_Tick(new EventHandler(this.dt_Tick));
					this._dt.Start();
					MapLayer.SetPosition(this.ellipseAccuracy, geoCoordinate);
					MapLayer.SetPositionOrigin(this.ellipseAccuracy, PositionOrigin.Center);
					this.myMap.AnimationLevel = AnimationLevel.None;
					this.myMap.Center = geoCoordinate;
					this.myMap.ZoomLevel = 16.0;
					this.myMap.UpdateLayout();
					this.ShowEllipseAccuracy();
				});
			}
		}
		private void myMap_MapZoom(object sender, MapZoomEventArgs e)
		{
			this.ShowEllipseAccuracy();
		}
		private void ShowEllipseAccuracy()
		{
		}
		private void HideEllipseAccuracy()
		{
		}
		private void dt_Tick(object sender, EventArgs e)
		{
			GeoCoordinate center = this.myMap.Center;
			if ((this._lastLat != double.NaN || this._lastLat != double.NaN) && this._lastLat == center.get_Latitude())
			{
				if (this._lastLng == center.get_Longitude())
				{
					this._indexForCenterChanging += 1u;
					if (this._indexForCenterChanging == 2u)
					{
						this._indexForCenterChanging = 0u;
						if ((this._lastLat != this.latitude || this._lastLng != this.longitude) && !this.isFingerPressed)
						{
							this.HideEllipseAccuracy();
							this.gridInfoSend.set_Visibility(1);
							this.StoryboardJump.Begin();
							Log.smethod_5("MapPage", "myMap_ViewChangeEnd MapEventArgs = " + e.ToString());
							Log.smethod_5("MapPage", "myMap.Center.Longitude = " + this.myMap.Center.get_Longitude());
							Log.smethod_5("MapPage", "myMap.Center.Latitude = " + this.myMap.Center.get_Latitude());
							this.latitude = this.myMap.Center.get_Latitude();
							this.longitude = this.myMap.Center.get_Longitude();
							this._hasGetAddress = false;
							this.GetData(this.latitude, this.longitude);
							this._isCenterChanging = false;
						}
					}
					return;
				}
			}
			this._lastLat = center.get_Latitude();
			this._lastLng = center.get_Longitude();
			this._isCenterChanging = true;
			this._indexForCenterChanging = 0u;
		}
		private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
		{
			try
			{
				TouchPointCollection touchPoints = e.GetTouchPoints(this.myMap);
				using (IEnumerator<TouchPoint> enumerator = touchPoints.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						TouchPoint current = enumerator.get_Current();
						if (current.get_Action() == 1)
						{
							this.isFingerPressed = true;
							return;
						}
					}
				}
				this.isFingerPressed = false;
			}
			catch
			{
			}
		}
		private void initGeoPostionSuccess()
		{
		}
		private void initGeoPostionFailed()
		{
			MMMessageBox mMMessageBox = MMMessageBox.Show(strings.Lbs_PeoList_MsgNoPos, true, "确定");
			mMMessageBox.ReturnEvent = new DlgReturnEvent(this.MsgBoxBackHandler);
		}
		private void geoDisable()
		{
			MMMessageBox mMMessageBox = MMMessageBox.Show(strings.Lbs_PeoList_MsgLbsOff, true, "确定");
			mMMessageBox.ReturnEvent = new DlgReturnEvent(this.MsgBoxBackHandler);
		}
		public void MsgBoxBackHandler(DlgReturnEventArg dlgReturnEventArg_0)
		{
			base.GoBack();
		}
		private void StopLocationService()
		{
			if (this.mGeoWatcher != null)
			{
				this.mGeoWatcher.Stop();
				this.mGeoWatcher = null;
				Log.smethod_5("MapPage", "StopLocationService");
			}
		}
		private void StoryboardJump_Completed(object sender, EventArgs e)
		{
			this.gridInfoSend.set_Visibility(0);
		}
		public void onGetAddressSuccess(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (evtArgs.mEventID == EventConst.ON_GETADDRESS_SUCCESS)
			{
				EventCenter.removeEventHandler(EventConst.ON_GETADDRESS_SUCCESS, new EventHandlerDelegate(this.onGetAddressSuccess));
				this._hasGetAddress = true;
				this.UpdatePushpin(MapPage.strAddress);
			}
		}
		private void UpdatePushpin(string address)
		{
			if (!string.IsNullOrEmpty(address))
			{
				Log.smethod_4("MapPage", "Get address success!");
				if (this._pageType == MapPage.PageType.SendPage)
				{
					this.tbAddressSend.set_Text(address);
					return;
				}
				if (!address.Equals(this.WAITSTRING))
				{
					this.tbAddressReceive.set_Text(address);
					this.tbAddressReceive.set_Visibility(0);
				}
			}
		}
		private string getAddressString(string address)
		{
			Log.smethod_5("MapPage", "address.Length = " + address.get_Length());
			return string.Copy(address);
		}
		private void GetData(double paramLatitude, double paramLongitude)
		{
			if (this.tempLat == paramLatitude)
			{
				if (this.tempLng == paramLongitude)
				{
					return;
				}
			}
			this.tempLat = paramLatitude;
			this.tempLng = paramLongitude;
			Log.smethod_5("MapPage", "Begin GetData");
			MapPage.strAddress = "";
			this.UpdatePushpin(this.WAITSTRING);
			string text = paramLatitude + "," + paramLongitude;
			string text2 = "&language=zh-CN&sensor=false";
			string text3 = "&language=en&sensor=false";
			string text4 = "&language=zh-TW&sensor=false";
			string text5;
			if (R.isChineseCN())
			{
				text5 = text2;
			}
			else
			{
				if (R.isChineseTW())
				{
					text5 = text4;
				}
				else
				{
					text5 = text3;
				}
			}
			if (this._request != null && !this._request.get_HaveResponse())
			{
				this._request.Abort();
				this._request = null;
			}
			this._request = (HttpWebRequest)WebRequest.Create("http://maps.google.com/maps/api/geocode/xml?latlng=" + text + text5);
			EventCenter.registerEventHandler(EventConst.ON_GETADDRESS_SUCCESS, new EventHandlerDelegate(this.onGetAddressSuccess));
			this._request.BeginGetResponse(delegate(IAsyncResult asyncResult)
			{
				try
				{
					HttpWebResponse httpWebResponse = (HttpWebResponse)this._request.EndGetResponse(asyncResult);
					XDocument xDocument = XDocument.Load(httpWebResponse.GetResponseStream());
					XElement xElement = xDocument.Element("GeocodeResponse");
					if (xElement != null)
					{
						Log.smethod_4("MapPage", "GeocodeResponse is a xml");
						XElement xElement2 = xElement.Element("status");
						if (xElement2 != null)
						{
							string value = xElement2.get_Value();
							if (value.Equals("OK"))
							{
								Log.smethod_4("MapPage", "request position info get right response!");
								using (IEnumerator<XElement> enumerator = xElement.Elements().GetEnumerator())
								{
									while (enumerator.MoveNext())
									{
										XElement current = enumerator.get_Current();
										XElement xElement3 = current.Element("type");
										if (xElement3 != null)
										{
											XElement xElement4 = current.Element("formatted_address");
											if (xElement4 != null)
											{
												MapPage.strAddress = xElement4.get_Value();
												Log.smethod_5("MapPage", "strAddress = " + MapPage.strAddress);
												EventCenter.postEvent(EventConst.ON_GETADDRESS_SUCCESS, null, null);
												return;
											}
										}
									}
								}
							}
						}
					}
					MapPage.strAddress = "";
					EventCenter.postEvent(EventConst.ON_GETADDRESS_SUCCESS, null, null);
				}
				catch (Exception ex)
				{
					MapPage.strAddress = "";
					EventCenter.postEvent(EventConst.ON_GETADDRESS_SUCCESS, null, null);
					Log.smethod_1("MapPage", ex.ToString());
				}
			}, null);
			Log.smethod_5("MapPage", "begin get location info");
		}
		private void OpenMapBtn_Click(object sender, EventArgs e)
		{
			if (this._pageType == MapPage.PageType.SendPage)
			{
				string mapMsgContent = ServiceCenter.sceneSendMsg.getMapMsgContent(this.latitude, this.longitude, (int)this.myMap.ZoomLevel - 1, this._hasGetAddress ? MapPage.strAddress : string.Empty);
				ChatMsg chatMsgInfo = ServiceCenter.sceneSendMsg.buildChatMsg(this._cuUser, mapMsgContent, 48);
				ServiceCenter.sceneSendMsg.doSendMsg(chatMsgInfo, 1);
				base.GoBack();
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Chat/Map/MapPage.xaml", 2));
			this.StoryboardJump = (Storyboard)base.FindName("StoryboardJump");
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.myMap = (Map)base.FindName("myMap");
			this.myMapTileLayer = (MapTileLayer)base.FindName("myMapTileLayer");
			this.mapLayerReceive = (MapLayer)base.FindName("mapLayerReceive");
			this.panelReceive = (Grid)base.FindName("panelReceive");
			this.gridInfoReceive = (Grid)base.FindName("gridInfoReceive");
			this.spInfoReceive = (StackPanel)base.FindName("spInfoReceive");
			this.tbUserLeft = (TextBlock)base.FindName("tbUserLeft");
			this.tbUserName = (TextBlock)base.FindName("tbUserName");
			this.tbUserRight = (TextBlock)base.FindName("tbUserRight");
			this.tbAddressReceive = (TextBlock)base.FindName("tbAddressReceive");
			this.imgPushinReceive = (Image)base.FindName("imgPushinReceive");
			this.mapLayerAccuracy = (MapLayer)base.FindName("mapLayerAccuracy");
			this.ellipseAccuracy = (Ellipse)base.FindName("ellipseAccuracy");
			this.panelSend = (Grid)base.FindName("panelSend");
			this.gridInfoSend = (Grid)base.FindName("gridInfoSend");
			this.tbAddressSend = (TextBlock)base.FindName("tbAddressSend");
			this.imgPushinSend = (Image)base.FindName("imgPushinSend");
			this.imgLogo = (Image)base.FindName("imgLogo");
			this.OpenMapBtn = (ApplicationBarIconButton)base.FindName("OpenMapBtn");
		}
	}
}
